local busitushou = fk.CreateSkill{
    name = "ym2__busitushou",
}
local DIY = require "packages/diy_utility/diy_utility"
Fk:loadTranslationTable{
    ["ym2__busitushou"] = "不死徒手",
    [":ym2__busitushou"] = "若你没有手牌，你可以如手牌般使用或打出牌堆顶的X张牌。（X为中央区牌数，至多为八）",

    ["$ym2__busitushou1"] = "飞身踢xN",
    ["$ym2__busitushou2"] = "（打斗声）",
}
busitushou:addEffect("filter",{
    handly_cards = function (self, player)
        if player:isKongcheng() and player:hasSkill(busitushou.name) then
            local n = math.min(#(Fk:currentRoom():getBanner("@$CenterArea") or {}),8)
            local ids = {}
            for i = 1, n, 1 do
                if i > #Fk:currentRoom().draw_pile then break end
                table.insert(ids, Fk:currentRoom().draw_pile[i])
            end
            if #ids <= #player:getTableMark("ym2__busitushou-turn") then
                return player:getTableMark("ym2__busitushou-turn")
            else
                return ids
            end
        end
    end,
})
busitushou:addEffect(fk.PreCardUse,{
    can_refresh = function (self, event, target, player, data)
        return player:hasSkill(busitushou.name) and target == player and #table.filter(Card:getIdList(data.card),function (id)
            return table.contains(player:getTableMark("ym2__busitushou-turn"),id)
        end) > 0
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        room:notifySkillInvoked(player,"ym2__busitushou","special")
        player:broadcastSkillInvoke("ym2__busitushou")
        local n = math.min(#(room:getBanner("@$CenterArea") or {}),8)
        local ids = {}
        for i = 1, n, 1 do
            if i > #room.draw_pile then break end
            table.insert(ids, room.draw_pile[i])
        end
        player.room:setPlayerMark(player, "ym2__busitushou-turn", ids)
    end,
})
local spec = {
    can_refresh = function (self, event, target, player, data)
        return player:hasSkill(busitushou.name)
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        local n = math.min(#(room:getBanner("@$CenterArea") or {}),8)
        local ids = {}
        for i = 1, n, 1 do
            if i > #room.draw_pile then break end
            table.insert(ids, room.draw_pile[i])
        end
        player.room:setPlayerMark(player, "ym2__busitushou-turn", ids)
    end,
}
busitushou:addEffect(fk.AskForCardUse,spec)
busitushou:addEffect(fk.AskForCardResponse,spec)
busitushou:addEffect(fk.AfterCardsMove,spec)
busitushou:addEffect(fk.AfterDrawPileShuffle,spec)
busitushou:addAcquireEffect(function (self, player, is_start)
    player.room:addSkill("#CenterArea")
end)
return busitushou